package com.shm.qianxin;

/**
 * @author: shm
 * @dateTime: 2020/9/25 20:53
 * @description:
 */
public class Solution {
    /**
     * 
     * @param tasks int整型一维数组 待加工的零件
     * @param n int整型 n的值
     * @return int整型
     */
    public int leastWorkTime (int[] tasks, int n) {
        // write code here
//        Arrays.sort(tasks);
        int[] ints = new int[10];
        for (int task : tasks) {
            ints[task]++;
        }

//        int maxCount = 0;
        int ans = 0;
        for (int anInt : ints) {
            int count = 0;
            if (anInt>0){
                ans +=anInt;
                count=(anInt-1)*n;
            }
            if (ans<count){
                ans+=count-ans;
            }
//            maxCount=Math.max(maxCount,count);
        }
//        return ans+maxCount;
        return ans;
    }
}